{extend name="base/index"/}

{block name="page_location"}
{block name="body"}
<div class="row">
	<div class="col-12">
		<div class="page-title-box">
			<div class="page-title-right">
				<ol class="breadcrumb m-0">
					<li class="breadcrumb-item">
						<a href="{:url('index/index')}">管理中心</a>
					</li>
					<li class="breadcrumb-item active"><i class="iconfont icon-angle-right"></i>模型管理列表</li>
				</ol>
			</div>
			<h4 class="page-title">
				{$page_title}
				<a href="javascript:;" data-toggle="modal" data-target="#new_box" id="add_mobel_btn" class="btn btn-success btn-sm ml-3">创建新的模型</a>
			</h4>
		</div>
	</div>
</div>
<div class="row" id="model_page">
	<div class="col-12">
		<div class="card">
			<div class="card-body">
				<div class="table-responsive-sm">

					<table class="table table-striped table-centered mb-0">
						<thead>
							<tr>
								<th>ID</th>
								<th>模型名称</th>
								<th>模型数据表</th>
								<th>模型数据表引擎</th>
								<th>模型状态</th>
								<th>模型创建时间</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							{volist name="list" id="data"}
							<tr>
								<td>{$data.id}</td>
								<td>{$data.model_name}</td>
								<td>{$data.model_table}</td>
								<td>{$data.model_engine}</td>
								<td>
									{eq name="data.status" value="0"}
									<a href="javascript:;" attr-model="model" attr-id="{$data.id}" class="badge badge-primary hidden_btn">启用</a>
									{else /}
									<a href="javascript:;" attr-model="model" attr-id="{$data.id}" class="badge badge-secondary show_btn">禁用</a>
									{/eq}
								</td>
								<td>{$data.posttime|date="Y-m-d H:i:s",###}</td>
								<td>
									<div class="btn-group mb-2">
										<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
										 aria-expanded="false">操作</button>
										<div class="dropdown-menu">
											<a class="dropdown-item edit_btn" href="javascript:;" attr-id="{$data.id}" data-toggle="modal" data-target="#new_box">修改模型</a>
											<!-- <a class="dropdown-item copy_btn" data-toggle="modal" data-target="#copy_box">复制模型</a> -->
											<a class="dropdown-item mobel_field_btn" href="{:url('modelfield/index')}?mid={$data.id}">字段管理</a>
											<!-- <div class="dropdown-divider"></div> -->
											<a class="dropdown-item Fast_Del" href="javascript:;" attr-id="{$data.id}" attr-model="model">删除</a>
										</div>
									</div>
								</td>
							</tr>
							{/volist}
						</tbody>
					</table>
				</div>
				<!-- end table-responsive-->
			</div>
			<!-- end card body-->
		</div>
		<!-- end card -->
	</div>
	<!-- end col-->
</div>
<!-- END PAGE CONTENT-->
{/block}
{block name="modal_dig"}
<!-- Modal -->
<div class="modal fade" id="new_box" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog  modal-full-70">
		<div class="modal-content">
			<div class="modal-header">
				<h4 class="modal-title dig_title" id="myModalLabel">创建新模型</h4>
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
			</div>
			<div class="modal-body">
				<form action="#" class="form-horizontal" id="edit_model_frm">
					<input type="hidden" name="id" value="" id="id" />
					<div class="form-group row mb-1">
						<label for="ipt_config_title" class="col-4 col-form-label">模型名称：</label>
						<div class="col-5">
							<input type="text" class="form-control ipt_check" data-type="string" data-type="name" data-len="5-20" nullmsg="模型名称不能为空"
							 errormsg="模型名称只能由2到10位的字母、数字组成" name="model_name" placeholder="请输入模型名称">
							<span class="font-13 text-muted">注：必填</span>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label for="ipt_config_title" class="col-4 col-form-label">模型数据表名：</label>
						<div class="col-5">
							<input type="text" class="form-control ipt_check" data-type="string" data-type="name" data-len="5-20" nullmsg="模型数据表名不能为空"
							 errormsg="模型数据表名只能由5到12位的下划线的任何单词字符和数字和中文组成" name="model_table" placeholder="请输入模型数据表名">
							<span class="font-13 text-muted">注：必填</span>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label for="ipt_isdeveloper" class="col-4 col-form-label">模型数据表引擎：</label>
						<div class="col-5">
							<div class="custom-control custom-radio">
								<input type="radio" name="model_engine" id="model_engine1" class="custom-control-input" value="MyISAM" checked="checked">
								<label class="custom-control-label" for="model_engine1">MyISAM</label>
							</div>
							<div class="custom-control custom-radio">
								<input type="radio" name="model_engine" id="model_engine2" class="custom-control-input" value="InnoDB">
								<label class="custom-control-label" for="model_engine2">InnoDB(支持事务)</label>
							</div>
							<span class="font-13 text-muted"></span>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label for="ipt_config_title" class="col-4 col-form-label">模型数据表备注：</label>
						<div class="col-5">
							<input type="text" class="form-control" name="model_table_comment" placeholder="请输入模型数据表名">
							<span class="font-13 text-muted"></span>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-4 col-form-label">模型描述：</label>
						<div class="col-5">
							<textarea name="description" rows="5" cols="description" class="form-control" placeholder="请输入模型描述"></textarea>
							<span class="help-inline"></span>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-4 col-form-label">模型状态：</label>
						<div class="col-5">
							<div class="custom-control custom-radio">
								<input type="radio" name="status" id="status1" class="custom-control-input" value="0" checked="checked">
								<label class="custom-control-label" for="status1">启用</label>
							</div>
							<div class="custom-control custom-radio">
								<input type="radio" name="status" id="status2" class="custom-control-input" value="1">
								<label class="custom-control-label" for="status2">禁用</label>
							</div>
							<span class="font-13 text-muted"></span>
						</div>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-light" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary Fast_Form_Post" attr-frm="#edit_model_frm" attr-model="model"  attr-callback="reload"
				 attr-active="save_model">立即提交</button>
			</div>
		</div>
	</div>
</div>

<div class="modal fade" id="create_table_box" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4 class="modal-title" id="myModalLabel">模型数据表操作</h4>
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
			</div>
			<div class="modal-body">
				<form action="" method="post" id="model_table_data_frm">
					<input type="hidden" name="mid" value="" />
					<input type="hidden" name="act" value="" />
					<p>
						<a href="#" class="btn blue" attr-act="table_all_rebuild">完全重新生成数据表(此模型下所有数据会丢失)</a>
					</p>
					<p>
						<a href="#" class="btn blue" attr-act="table_update_rebuild">根据修改更新数据表</a>
					</p>
					<p>
						<a href="#" class="btn blue" attr-act="table_drop">删除数据表</a>
					</p>
					<p>
						<a href="#" class="btn blue" attr-act="table_clear_data">清空数据表数据</a>
					</p>
				</form>
			</div>
		</div>
	</div>
</div>
{/block}
<!--   -->
